/**
 * 
 */
package com.tdkj.action.front.member.account;

import java.sql.Timestamp;

import javax.annotation.Resource;

import org.hibernate.Query;

import com.tdkj.action.BaseAction;
import com.tdkj.model.user.BeanUser;
import com.tdkj.model.website.BeanComplaint;
import com.tdkj.service.website.IBeanComplaintService;

/**
 * @author yninfo
 */
public class ComplaintAction extends BaseAction {
	
	private BeanComplaint bean ;
	private IBeanComplaintService complaintService;
	
	public String execute(){
		
		BeanUser user = this.getCurrentUser();
		
		String hql = "from " + BeanComplaint.class.getName() + " as bean where bean.user.id='"+user.getId()+"' ";
		Query query  = this.createQuery(hql);
		
		this.queryByPage(query, "complaintAction.action", 10);
		
		return "success";
	}
	
	
	public String add(){
		BeanUser user = this.getCurrentUser();
		bean.setUser(user);
		bean.setCreatetime(new Timestamp(System.currentTimeMillis()));
		complaintService.save(bean);
		return execute();
	}
	

	public BeanComplaint getBean() {
		return bean;
	}

	public void setBean(BeanComplaint bean) {
		this.bean = bean;
	}

	@Resource
	public void setComplaintService(IBeanComplaintService complaintService) {
		this.complaintService = complaintService;
	}
	
}
